Buffer-based update of state data

ABSTRACT

Example implementations relate to buffer-based update of state data. In example embodiments, a computing device may obtain current state data from a first buffer and determine next state data based at least on the current state data. The computing device may also obtain last difference data that corresponds, for example to current state data that is different from previous state data. The last difference data may be obtained, for example, using a difference data identifier. The computing device may store the last difference data in the second memory buffer. The computing device may also store in the second memory buffer new difference data corresponding to differences between the next state data and the current state data. The computing device may also update the difference data identifier based on the new difference data.

BACKGROUND

Computers can perform system simulations and real-time system control by considering time discretely. For example, a computer can maintain a memory of the system's state at a given point in time, and update the state in small time increments, determining the next state based on the current state and any additional inputs. Some systems, such as systems for climate simulation or face recognition, may require vast amounts of data to accurately represent their state.

BRIEF DESCRIPTION OF THE DRAWINGS

The following detailed description references the drawings, wherein:

FIG. 1 is a block diagram of an example computing device, consistent with implementations of the present disclosure;

FIG. 2 is a flowchart of an example method for buffer-based update of state data, consistent with implementations of the present disclosure; and

FIGS. 3A-3F are partial block diagrams of an example machine-readable storage medium, consistent with implementations of the present disclosure.

DETAILED DESCRIPTION

As detailed above, computers may perform simulations and real-time system control by maintaining and updating state data describing the system's state. As the systems become more complex, however, the amount of data required to accurately represent their states increases dramatically. To maintain and process large amounts of data efficiently, a computer may break the state data into portions and process each portion independently. Processing efficiency can also be increased by processing the state data using a number of processors operating in parallel, where each processor may independently process current state data (e.g., state data that is currently stored in memory) and output a different portion of next state data, where the different portions may have some overlap.

Such distributive processing techniques, however, may be prone to data corruption if only one copy of state data is maintained in memory. For example, if a processor calculates and outputs a portion of next state data overwriting some current state data, another or same processor may subsequently read the overwritten data, incorrectly treating it as current state data. To ensure correct and deterministic state transitions, a double-buffering scheme may be employed, where a first memory buffer may hold the system state, for example, for all the even-numbered states, and the second memory buffer may hold the system state for all the odd-numbered states. When computing an odd-numbered state, one or more processors may read from the first memory buffer and write to the second memory buffer, and when computing an even-numbered state, the processors may read from the second memory buffer and write to the first memory buffer. This way, data coherency can be ensured even if various portions of the state data are processed in a non-deterministic order.

However, in such double-buffered configurations, if the processor(s) output and store only those portions of the next state data that are different from the current state data, the memory buffer serving as the output buffer may not end up accurately representing the next state, even if both buffers are initialized identically, because it may not reflect the differences between the current state data and the previous state data. since those differences were only stored in the other buffer, currently serving as the input buffer. One way to avoid this is to always output the entire next state data, and not just state data that has changed from the current state to the next state. However, writing the entire state data at each state transition may be a time- and resource-consuming task, particularly for systems represented by large state data sizes, systems requiring fast state updates, or both.

Example implementations disclosed herein relate to buffer-based update of state data. In example implementations, a computing device may obtain current state data from a first buffer and determine next state data based at least on the current state data. The computing device may also obtain last difference data that corresponds, for example to current state data that is different from previous state data. The last difference data may be obtained, for example, using a difference data identifier. The computing device may store the last difference data in the second memory buffer. The computing device may also store in the second memory buffer new difference data corresponding to differences between the next state data and the current state data. The computing device may also update the difference data identifier based on the new difference data.

In this manner, example implementations disclosed herein ensure data coherency during state transitions, without requiring that entire state data is copied at each transition. Example implementations thereby increase system performance, minimize system's hardware and/or software requirements, reduce system's cost and power consumption, and so forth. Additional implementations and advantages of such implementations will be apparent to those of skill in the art upon reading and understanding the following description.

Referring now to the drawings, FIG. 1 is a block diagram of an example computing device 100. While schematically shown as a single device, it is appreciated that computing device 100 may include one or more computing devices, such as electronic devices, bio-computers, or other devices capable of performing the functionality discussed below. For example, computing device 100 may include any combination of one or more electronic devices such as server computers, desktop computers, notebook computers, tablet computing devices, mobile phones, or any other suitable electronic devices. In the example implementation of FIG. 1, electronic device 100 includes processor 110, and machine-readable storage medium 120.

Processor 110 may include one or more processing units, such as central processing units (CPUs), graphics processing units (GPUs), microprocessors, and/or other hardware devices suitable for retrieval and execution of instructions stored, for example, in machine-readable storage medium 120. For example, processor 110 may fetch, decode, and execute buffer-based state data update instructions 150, as described above. As an alternative or in addition to retrieving, decoding, and executing instructions, processor 110 may include one or more electronic circuits comprising a number of electronic components for performing buffer-based state data update instructions 150. In some implementations, the one or more processing units and/or electronic circuits may be configured to operate in parallel to perform buffer-based state data update instructions 150.

Machine-readable storage medium 120 may be, for example, one or more electronic, magnetic, optical, or other physical storage devices that may store executable instructions. Thus, machine-readable storage medium 120 may include, for example, Random Access Memory (RAM), an Electrically-Erasable Programmable Read-Only Memory (EEPROM), a flash memory, a memristor-based memory, a storage drive, an optical disc, and the like. Accordingly, machine-readable storage medium 120 may include volatile memory and/or non-volatile memory. In some examples, machine-readable storage medium 120 may be a non-transitory storage medium, where the term “non-transitory” does not encompass transitory propagating signals. Machine-readable storage medium 120 may store, among other things, buffer-based state data update instructions 150 and buffers 130 a, 130 b, and 140 used by buffer-based state data update instructions 150, as discussed below.

FIG. 2 is a flowchart representing an example method 200 for buffer-based update of system state data. While the flowchart discloses the following blocks in a particular order, it is appreciated that at least some of the blocks may be moved, modified, or deleted where appropriate, consistent with the teachings of the present disclosure. Method 200 can be performed by one or more computing devices, such as computing device 100. Method 200 may be implemented in the form of instructions, such as state data update instructions 150, which may be stored on a machine-readable storage medium, such as machine-readable storage medium 120, and executable by a processor, such as processor 110. Alternatively or in addition, method 200 may be implemented in part or in its entirety in the form of electronic circuitry

At block 210, computing device 100 may initialize a first memory buffer and a second memory buffer with initial state data. In some implementations, the first and second memory buffers may include memory buffers 130 a and 130 b stored in machine-readable storage medium 120 of computing device 100. In other implementations, one or both of the first and second memory buffers may be stored on another device, such as a network server, which may be remotely accessible by computing device 100. Each memory buffer may be stored entirely on a single device or over a number of devices, and may be implemented in the form of any type of data structure allowing storage, retrieval, and update of a plurality of values. For example, the memory buffers may be implemented as one-dimensional arrays, two-dimensional arrays, multi-dimensional arrays, trees, heaps, linked lists, database tables, and the like.

Each memory buffer may store, among other things, state data describing a given state of a given system, such as a system being simulated or controlled by computing device 100. State data may include, for example, a plurality of values that describe the system state. For example, if the system is a climate system, the plurality of values may include temperatures, wind speeds, humidity levels, and other climate parameters associated with one or more geographical areas. Each of the plurality of values describing the system state may be stored at a specific location within the memory buffer. Each location may be described by an identifier, which may be an address, such as an absolute memory address (e.g., an absolute address within machine-readable storage medium 120) or a relative memory address (e.g., an offset within the respective memory buffer). An identifier may also include an index value, or any other type of information identifying a particular value within the memory buffer and thereby allowing computing device 100 to store, retrieve and/or update the particular value.

Initializing the first and second memory buffers with initial state data in block 210 may include writing to or storing in each of the memory buffers identical initial state data that may include a plurality of predetermined or default values. The initialization may also include designating one of the memory buffers as the first memory buffer and the other memory buffer as the second memory buffer. In some implementations, the initial designation may be arbitrary, and the designation may be dynamically changed by computing device 100, as discussed below.

At block 215, computing device 100 may obtain current state data from the first memory buffer, that is, the memory buffer that is currently designated as the first memory buffer. Computing device 100 may read from the first memory buffer all current state data, or, in some implementations, only that portion of current state data that may be used for determining the next state data.

At block 220, computing device 100 may determine next state data based at least on the current state data. For example, in case of a climate system simulation, computing device 100 may determine, based on climate data a “current” point in time (which can be in the past, present, or future), climate data at a next point in time, which can be, for example, a predetermined time period (e.g., a second, a minute, a day, etc.) after the current point in time. In some implementations, computing device 100 may use one or more models, such as a climate model, for determining next state data based on current state data.

In some implementations, computing device 100 may determine next state data based on current state data and one or more additional inputs, such as user inputs or real-time sensor inputs such as image sensors, audio sensors, motion sensors, and the like. In these implementations, computing device 100 may wait for additional inputs to be obtained before proceeding to determine next state data.

For some systems, such as climate or face recognition systems, computing device 100 may need to read most or all of current state data to determine next state data, but the determined next state data may have a limited number (e.g., less than 10% or less than 1%) of changes or differences relative to current state data. Therefore, in some implementations, determining next state data may include determining only the differences between the current state data and the next state data. Hereinafter, the portion of state data that changes between two subsequent states may be referred to as “difference data,” and state data that does not change between two subsequent states may be referred to as “unchanged data”

At block 225, computing device 100 may obtain last difference data, i.e., any portion of state data that changed from the previous state to the current state. It is appreciated that difference data may sometimes include no data, for example, if the current state is the first state, or wnen the last state data was identical to the current state data. In some implementations, computing device 100 may obtain last difference data from the first memory buffer by first obtaining one or more difference data identifiers that identify one or more locations of the last difference data in the memory buffer.

Difference data identifiers may be stored in a buffer, such as difference data identifiers buffer 140, which may be stored in machine-readable storage medium 120 of computing device 100 or on another device remotely accessible by computing device 100. Difference data identifiers buffer 140 may be implemented, for example, using any data structure suitable for storing a plurality of values, such as a one-dimensional array, a linked list, and the like. Difference data identifiers may identify individual addresses and/or ranges of addresses at which difference data is stored in the memory buffer. In some implementations, if difference data identifiers include regions, the regions may include data other than difference data. For example, if the memory buffer is a two-dimensional N×M array and difference data is scattered across the array, difference data identifiers may identify one or more windows within the N×M array that include difference data and potentially some unchanged data. An identifier may identify its respective window, for example, by identifying the window's opposite corners or one of the window's corner and the window's dimensions. While some additional writing or storing operations may be required due to potential inclusion of unchanged data in the regions, storing region identifiers may reduce the amount of memory required for identifying the difference data.

In some implementations, computing device 100 may obtain difference data addresses directly from the first memory buffer without first obtaining difference data identifiers. For example, if the first memory buffer is implemented using a data structure that supports flagging recently changed data, computing device 100 can directly read from the first memory buffer any recently changed data that may correspond to last difference data. In some implementations, instead of obtaining last difference data from the first memory buffer, computing device 100 may obtain last difference data from another buffer that may, for example, temporarily store a copy of last difference data.

At block 230, computing device 100 may store the obtained last difference data, if any, in the second memory buffer. For example, computing device 100 may write the last difference data to one or more corresponding locations in the second memory buffer. In some implementations, the first and the second memory buffers may have a similar or identical structure (e.g., both can be one-dimensional arrays of similar size), in which case computing device 100 may store the last difference data in the second memory buffer at locations corresponding to the last difference data's locations in the first memory buffer, for example, at the same offset addresses, at the same indexes, and so forth. In some implementations, in block 230, computing device may store last difference data only, without storing any data that has not changed from the last state to the current state. In other implementations, some unchanged data may be stored along with last difference data, for example, due to range identifiers discussed above and/or because computing device 100 may have a minimum storage unit (e.g., 128 bytes) in which case storing a portion of last difference data that is smaller than the minimum storage unit may require storing some unchanged data, as well. It is appreciated, however, that even if some amount of unchanged data is stored at block 230 due to overheads, that amount may be limited and, for example, may not exceed the amount of last difference data.

At block 235, computing device 100 may store in the second memory buffer new difference data—the portion of the determined next state data that is different from the current state data. Computing device may store new difference data only, without storing some or any data that has not changed from the current state to the next state. As discussed above, not having to store most (e.g., more than 50%) or all of unchanged next state data may save numerous write operations, thereby increasing performance, reducing system costs and power consumption, etc.

As mentioned above, while the flowchart discloses the blocks of method 200 in a particular order, it is appreciated that at least some of the blocks may be moved, modified, or deleted where appropriate, consistent with the teachings of the present disclosure. For example, computing device 100 may perform blocks 225 and 230 before or in parallel to performing blocks 215 and 220. In some implementations, however, computing device 100 may begin performing block 235 for storing new difference data only after it finishes storing all last difference data in block 230. Because of a potential overlap between new difference data and last difference data (i.e., where some data changed from the previous state to the current state and then changed again from the current state to the next state) writing new difference data after last difference data may prevent last difference data from overwriting new difference data.

At block 240, computing device 100 may update difference data identifiers based on the new difference data stored in block 235. For example, computing device may store in difference data identifiers buffer 140 one or more identifiers that identify where new difference data was stored in the second memory buffer. As discussed above, difference data identifiers may identify the location of the difference data in the memory buffer by specifically identifying each address or index at which difference data is stored in the memory buffer and/or by identifying regions (e.g., one-dimensional regions or two-dimensional windows) within the memory buffer that include difFerence data.

While block 240 follows block 235 in the flowchart, it is appreciated that computing device 100 may not need to finish storing new difference data before beginning to update difference data identifiers. For example, in some implementations, difference data identifiers may be updated with new difference data as soon as last difference data has been stored, and next state data has been determined.

In some implementations, difference data identifiers buffer 140 may be implemented as a double buffer, allowing computing device 100 to store last difference data identifiers in one buffer, and new difference data identifiers in another buffer. In these implementations, computing device 100 may not need to wait for last difference data to be stored in block 235 before updating difference data identifiers buffer 140 with identifiers corresponding to new difference data.

At block 245, computing device 100 may determine whether the next state for which next state data was determined in block 220 is the final state of the system, and if so, method 200 may end. Otherwise, method 200 may proceed to block 250 where computing device 100 may swap the first and second memory buffers, for example, by re-designating the first memory buffer as the second memory buffer, and by re-designating the second as the first memory buffer. From block 250, the method may then proceed to block 215.

As mentioned above, method 200 may include additional blocks, not shown in FIG. 2 for reasons of brevity. For example, after computing device 100 determines next state data, computing device 100 may display next state data on a display coupled to computing device 100, and/or store the next state data (or only new difference data), for example, into a file. In some implementations, computing device 100 may provide for display a graphical user interface (GUI) through which computing device 100 may, for example, present state data to the user and receive user inputs. As discussed above, in some implementations, user inputs may be used by computing device 100 in determining next state data. Additionally, user inputs may be used to pause execution of method 200, “rewind” method 200 backward or forward, and otherwise control the execution of method 200. The GUI may be provided by computing device 100 on a display physically or remotely coupled to computing device 100.

Method 200 can be further illustrated by an example in FIGS. 3A-3F, showing example contents of buffers 130 a, 130 b, and 140, as they change during execution of method 200. As discussed above, while some blocks of method 200 are described as being performed in a particular order, it is appreciated that in some implementations the order may be modified.

In the example of FIG. 3A, buffers 130 a and 130 b are initialized (210) to store initial state data, symbolically indicated by characters ‘X ,’ ‘Y,’ and ‘Z.’ Buffer 130 a is initially designated as the first memory buffer and buffer 130 b is initially designated as the second memory buffer. Buffer 140 is initialized to contain no last difference data identifiers because last difference data is not available at this initial state.

Next, current state data is obtained (215) from the first memory buffer, currently buffer 130 a. Based on the obtained current state data (and, in some implementations, based also on additional inputs) next state data is determined (220). In this example, next state data is determined to be different from current state data by two values, which are symbolically indicated by “A” and “B,” and which constitute new difference data in this case.

Next, last difference data is obtained (225) from first memory buffer and stored (230) in second memory buffer, currently buffer 130 b. At this stage, there is no last difference data, as indicated by an empty difference data identifiers buffer 140.

As illustrated in FIG. 3B, new difference data (“A” and “B”) is then stored (235) in the second memory buffer, currently buffer 130 b, and buffer 140 is updated (240) to include identifiers identifying the new difference data. In this example, the identifiers include two addresses Adr(A) and Adr(B), which may be absolute or relative offset addresses, and which identify the locations of values “A” and “B” within the second memory buffer, currently buffer 130 b.

In this example, after updating buffer 140, it is determined (245) that the next state is not the final state. Based on this determination, the first and second memory buffers are swapped (250) to cause the first memory buffer to correspond to buffer 130 b and to cause the second memory buffer to correspond to buffer 130 a.

Next, current state data is obtained (215) from the first memory buffer, currently buffer 130 b, and next state data is determined (220) based at least on the obtained current state data. In this example, next state data includes only one new value, indicated by “C.”

Last difference data is then obtained (225) from the first memory buffer, currently buffer 130 b. As discussed above, last difference data may be obtained from the first memory buffer by using last difference data identifiers stored in buffer 140. Accordingly, in this example, identifiers Adr(A) and Adr(B) stored in buffer 140 may be used to obtain last difference data “A” and “B” from the first memory buffer, currently buffer 130 b. Last difference data is then stored (230) in the second memory buffer, currently buffer 130 a, as shown in FIG. 3C.

Next, as shown in FIG. 3D, new difference data (“C”) is stored (235) in the second memory buffer, currently buffer 130 a, and buffer 140 is updated (240) to store identifier Adr(C) identifying the location of new difference data in the second memory buffer. It is then determined (245) that the next state is not the final state, and the first and second memory buffers are swapped (250) again such that the first memory buffer now corresponds to buffer 130 a and the second memory buffer now corresponds to buffer 130 b.

Next, current state data is obtained (215) from the first memory buffer, currently buffer 130 a, and next state data is determined (220) based at least on the obtained current state data. In this example, next state data includes new values “D,” “E,” “F,” and “G.” In addition, last difference data (“C”) is obtained (225) from the first memory buffer by using identifier Adr(C) stored in buffer 130 b. Last difference data is then stored (230) in the second memory buffer, currently buffer 130 b, as shown in FIG. 3E.

Next, as shown in FIG. 3F, new difference data (“D,” “E,” “F,” and “G”) is stored (235) in the second memory buffer, currently buffer 130 b, and buffer 140 is updated (240) to store identifiers identifying the location of new difference data in the second memory buffer. In this example, the stored identifiers include a range identifier Adr(D)-Adr(F) and a specific identifier Adr(G). Next, if it is determined (245) that the next state is the final state, method 200 will end; otherwise, method 200 will continue to swap buffer (250) again, to obtain current state data (215), and so forth until the final state is reached.

According to the foregoing, example implementations disclosed herein enable a computing device to update a system's state data in a manner that maintains data coherency without requiring storing the entire state data at each state transition, thereby increasing system performance, reducing power consumption, reducing system cost, etc. 

What is claimed is:
 1. A method comprising: obtaining current state data from a first memory buffer; determining next state data based at least on the current state data; obtaining last difference data from the first memory buffer based on at least one difference data identifier; storing in a second memory buffer last difference data representing differences between last state data and the current state data; storing in the second memory buffer new difference data representing differences between the next state data and the current state data; and updating the difference data identifier based on the new difference data.
 2. The method of claim 1, wherein the new difference data is stored in the second memory buffer after the last difference data is stored in the second memory buffer.
 3. The method of claim 1, wherein the new difference data is stored at at least one address in the second memory buffer, and the updated difference data identifier identifies the at least one address.
 4. The method of claim 3, wherein the first and second memory buffers comprise two-dimensional buffers, and the updated difference data identifier identifies a two-dimensional window comprising the at least one address.
 5. The method of claim 1, wherein the difference data identifier is stored in a difference data identifier buffer implemented as a double buffer.
 6. The method of claim 1, wherein the determination of the next state data is performed by a plurality of processors operating in parallel, each of the plurality of processors determining a different portion of the next state data.
 7. A computing device comprising: at least one processor to: determine next state data based at least on current state data, the current state data being determined based at least on last state data and stored in a first memory buffer; store in a second memory buffer a portion of the current state data that is different than the last state data; and store in the second memory buffer only a first portion of the next state data, without storing at least a second portion of the next state data.
 8. The computing device of claim 7, wherein the first portion of the next state data is stored in the second memory buffer after the portion of the current state data is stored in the second memory buffer.
 9. The computing device of claim 7, wherein the first portion of the next state data is stored at least one address in the second memory buffer, and the processor is further configured to: store at least one difference data identifier identifying the at least one address.
 10. The computing device of claim 7, wherein the processor is further configured to: initialize the first memory buffer to store initial state data; and initialize the second memory buffer to store the initial state data.
 11. The computing device of claim 9, wherein the difference data identifier is stored in a difference data identifier buffer implemented as a double buffer.
 12. The computing device of claim 7, wherein the processor comprises a plurality of processors operating in parallel, each of the plurality of processors determining a different portion of the next state data.
 13. A non-transitory machine-readable storage medium encoded with instructions which, when executed by a processor, cause the processor to: determine next state data based at least on current state data, the current state data being determined based at least on last state data and stored in a first memory buffer; obtain last difference data from the first memory buffer based on at least one difference data identifier; store in a second memory buffer last difference data representing differences between last state data and the current state data; and store in the second memory buffer new difference data representing differences between the next state data and the current state data.
 14. The non-transitory computer-readable medium of claim 13, wherein the new difference data is stored in the second memory buffer after the last difference data is stored in the second memory buffer.
 15. The non-transitory computer-readable medium of claim 13, wherein the instructions further cause the processor to: update the difference data identifier based on the new difference data. 